<extend name="Public/base"/>

<block name="body">
  <style type="text/css">
  #img-box{
    height:200px;
    width: 150px;
    margin: 5px 0;
  }
  </style>
    <div class="main-title">
        <h2>编辑图书</h2>
    </div>
    <form action="{:U()}" method="post" enctype="multipart/form-data" class="form-horizontal">
  <div class="form-item">
  <input type="hidden"name="id" value="{$book.id}">
    <label>图书名称</label>
    <input type="text" class="form-control" name="bookname" value="{$book.bookname}">
  </div>
  <div class="form-item">
    <label>图书类别</label>
    <select class="form-control" name="category" >
		<volist name="Book_Category" id="vo" offset="1" key="k">
		<option value = {$k+1} <if condition="$book['category']==$k+1">selected<else/></if>>{$vo}</option>
		</volist>
	</select>
  </div>
  <div class="form-item">
    <label>图片封面</label>
    <input id="file_upload" name="file_upload" type="file"
        multiple="true" value="" />
        <img id="img-box" src="__ROOT__{$book.cover}">
    <input id="cover" type="hidden"  name="cover" value="{$book.cover}" />
  </div>
  <div class="form-item">
    <label>图书作者</label>
    <input type="text" class="form-control" name="author" value="{$book.author}">
  </div>
  <div class="form-item">
    <label>图书出版社</label>
    <input type="text" class="form-control" name="press" value="{$book.press}">
  </div>
  <div class="form-item">
    <label>图书isbn号</label>
    <input type="text" class="form-control" name="isbn" value="{$book.isbn}">
  </div>
  <div class="form-item">
    <label>图书页数</label>
    <input type="text" class="form-control" name="book_page" value="{$book.book_page}">
  </div>
  
    <div class="form-item">
    <label>图书简介</label>
    <textarea class="form-control" rows="3" name="intro" >{$book.intro}</textarea>
  </div>
  <!--
  <div class="form-item">
    <label>图书简介</label>
    <textarea name="intro">{$book.intro}</textarea>
         {:hook('adminArticleEdit', array('name'=>intro,'value'=>$book.intro))} 
  </div>-->
  <div class="form-item">
  		<input class="btn submit-btn ajax-post" type="submit" id="submit" value="确 定" target-form="form-horizontal"/>
      <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
  </div>
  </volist>
</form>
</block>

<block name="script">
    <script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
  <script type="text/javascript">
    //导航高亮
    highlight_subnav('{:U('Book/index')}');
    $(function(){
      var img  = '';
      $("#file_upload").uploadify({
        "height"          : 30,
        "swf"             : "__STATIC__/uploadify/uploadify.swf",
        "fileObjName"     : "download",
        "buttonText"      : "上传图片",
        "uploader"        : "{:U('File/uploadPicture',array('session_id'=>session_id()))}",
        "width"           : 150,
        'removeTimeout'   : 1,
        'fileTypeExts'    : '*.jpg; *.png; *.gif;',
        "onUploadSuccess" : uploadPicture,
        'onFallback' : function() {
            alert('未检测到兼容版本的Flash.');
        }
    });
  function uploadPicture(file, data){
      var data = $.parseJSON(data);
      var src  = '';
      if(data.status){
        src = data.url || '__ROOT__' + data.path;
        $("#img-box").attr("src",src);
        $("#cover").val(data.path);
      } else {
        updateAlert(data.info);
        setTimeout(function(){
              $('#top-alert').find('button').click();
              $(that).removeClass('disabled').prop('disabled',false);
          },1500);
      }
    }
    })
    
</script>
</block>
